Quartz: Implement gdk_window_set_functions
authorMatthias Clasen <mclasen@redhat.com>
Mon, 6 Mar 2017 03:52:03 +0000 (22:52 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 6 Mar 2017 03:52:03 +0000 (22:52 -0500)
This is useful, and easy to implement.

gdk/quartz/gdkwindow-quartz.c

index 5f3efd8011168d5a4265ecf243fe59e171c3088f..803d3b99d152641fea52fc7db764b26a0d4c5ccc 100644 (file)
@@ -2324,9 +2324,47 @@ static void
 gdk_quartz_window_set_functions (GdkWindow    *window,
                                  GdkWMFunction functions)
 {
+  GdkWindowImplQuartz *impl;
+  gboolean min, max, close;
+
   g_return_if_fail (GDK_IS_WINDOW (window));
 
-  /* FIXME: Implement */
+  imple = GDK_WINDOW_IMPL_QUARTZ (window->impl);
+
+  if (functions & GDK_FUNC_ALL)
+    {
+      min = !(functions & GDK_FUNC_MINIMIZE);
+      max = !(functions & GDK_FUNC_MAXIMIZE);
+      close = !(functions & GDK_FUNC_CLOSE);
+    }
+  else
+    {
+      min = (functions & GDK_FUNC_MINIMIZE);
+      max = (functions & GDK_FUNC_MAXIMIZE);
+      close = (functions & GDK_FUNC_CLOSE);
+    }
+
+  if (impl->toplevel)
+    {
+      NSWindowStyleMask mask = [impl->toplevel styleMask];
+
+      if (min)
+        mask = mask | NSMiniaturizableWindowMask;
+      else
+        mask = mask & ~NSMiniaturizableWindowMask;
+
+      if (max)
+        mask = mask | NSResizableWindowMask;
+      else
+        mask = mask & ~NSResizableWindowMask;
+
+      if (close)
+        mask = mask | NSClosableWindowMask;
+      else
+        mask = mask & ~NSClosableWindowMask;
+
+      [impl->toplevel setStyleMask:mask];
+    }
 }
 
 static void